/// <reference path="_variables.scss" />
/// <reference path="_functions.scss" />
/// <reference path="_mixins.scss" />

// Base class
//
// Kickstart any navigation component with a set of style resets. Works with
// `<nav>`s, `<ul>`s or `<ol>`s.

.nav {
  --nav-link-padding-x: #{$nav-link-padding-x};
  --nav-link-padding-y: #{$nav-link-padding-y};
  @include rfs($nav-link-font-size, --nav-link-font-size);
  --nav-link-font-weight: #{$nav-link-font-weight};
  --nav-link-color: #{$nav-link-color};
  --nav-link-hover-color: #{$nav-link-hover-color};
  --nav-link-disabled-color: #{$nav-link-disabled-color};
  --nav-link-transition: #{$nav-link-transition};

  display: flex;
  flex-wrap: wrap;
  padding-inline-start: 0;
  margin-bottom: 0;
  list-style: none;
}

.nav-link {
  display: block;
  padding: var(--nav-link-padding-y) var(--nav-link-padding-x);
  @include font-size(var(--nav-link-font-size));
  font-weight: var(--nav-link-font-weight);
  color: var(--nav-link-color);
  background: none;
  border: 0;
  text-decoration: if($link-decoration == none, null, none);
  transition: var(--nav-link-transition);

  &:hover,
  &:focus {
    color: var(--nav-link-hover-color);
    text-decoration: if($link-hover-decoration == underline, none, null);
  }

  &:focus-visible {
    box-shadow: $nav-link-focus-box-shadow;
  }

  // Disabled state lightens text
  &.disabled,
  &:disabled {
    color: var(--nav-link-disabled-color);
    pointer-events: none;
    cursor: default;
  }
}

//
// Tabs
//

.nav-tabs {
  --nav-tabs-border-width: #{$nav-tabs-border-width};
  --nav-tabs-border-color: #{$nav-tabs-border-color};
  --nav-tabs-border-radius: #{$nav-tabs-border-radius};
  --nav-tabs-link-hover-border-color: #{$nav-tabs-link-hover-border-color};
  --nav-tabs-link-active-color: #{$nav-tabs-link-active-color};
  --nav-tabs-link-active-bg: #{$nav-tabs-link-active-bg};
  --nav-tabs-link-active-border-color: #{$nav-tabs-link-active-border-color};

  border-bottom: var(--nav-tabs-border-width) solid var(--nav-tabs-border-color);

  .nav-link {
    margin-bottom: calc(-1 * var(--nav-tabs-border-width));
    border: var(--nav-tabs-border-width) solid transparent;
    @include border-top-radius(var(--nav-tabs-border-radius));

    &:hover,
    &:focus {
      // Prevents active .nav-link tab overlapping focus outline of previous/next .nav-link
      isolation: isolate;
      border-color: var(--nav-tabs-link-hover-border-color);
    }
  }

  .nav-link.active,
  .nav-item.show .nav-link {
    color: var(--nav-tabs-link-active-color);
    background-color: var(--nav-tabs-link-active-bg);
    border-color: var(--nav-tabs-link-active-border-color);
  }

  .dropdown-menu {
    // Make dropdown border overlap tab border
    margin-top: calc(-1 * var(--nav-tabs-border-width));
    // Remove the top rounded corners here since there is a hard edge above the menu
    @include border-top-radius(0);
  }
}


//
// Pills
//

.nav-pills {
  --nav-pills-border-radius: #{$nav-pills-border-radius};
  --nav-pills-link-active-color: #{$nav-pills-link-active-color};
  --nav-pills-link-active-bg: #{$nav-pills-link-active-bg};

  .nav-link {
    @include border-radius(var(--nav-pills-border-radius));
  }

  .nav-link.active,
  .show > .nav-link {
    color: var(--nav-pills-link-active-color);
    @include gradient-bg(var(--nav-pills-link-active-bg));
  }
}


//
// Justified variants
//

.nav-fill {
  > .nav-link,
  .nav-item {
    flex: 1 1 auto;
    text-align: center;
  }
}

.nav-justified {
  > .nav-link,
  .nav-item {
    flex-basis: 0;
    flex-grow: 1;
    text-align: center;
  }
}


// Tabbable tabs
//
// Hide tabbable panes to start, show them when `.active`

.tab-content {
  > .tab-pane {
    display: none;
  }
  > .active {
    display: block;
  }
}
